"""
This module provides functions to simplify the sending of email 
documents.  SMTP parameters and default options are collected 
from config.py, with the actual message data being provided as 
function parameters.
"""

import smtplib
import config
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText

def sendHTMLMail(me = config.mail_from, 
	you = config.mail_to, 
	subject = config.mail_subject,
	text = config.mail_text,
	html = config.mail_text):
  """Composes and sends an HTML message with a plaintext 
  alternative version"""
  print you
  
  #Create message container
  msg = MIMEMultipart('alternative')
  msg['Subject'] = subject
  msg['From'] = me
  msg['To'] = ', '.join(you)

  #Record the MIME types of both parts - text/plain and text/html
  part1 = MIMEText(text, 'plain')
  part2 = MIMEText(html, 'html')
  
  #Attach parts to the message container
  msg.attach(part1)
  msg.attach(part2)

  #Send the message via SMTP
  s = smtplib.SMTP(config.mail_server)
  s.sendmail(me, you, msg.as_string() )
  s.quit()
